package YAPserver.mods;

import YAPenvironment.YAPconstant.ModState;
import YAPserver.behaviours.BounceMirror;
import YAPserver.behaviours.BounceRandom;
import YAPserver.gameObjects.Mod;
import YAPserver.logic.GameModifier;
import YAPserver.logic.Player;
/**
 * A global ModBehaviour.
 * When this modBehaviour's modify method is called all ballAbstracts bounce randomly.
 * The demodify method sets the bounceBehaviours back to normal once the mod's timer has reached 0.
 * @author Daniel
 *
 */
public class ModWallRandomBounce extends AbstractStandardMod{
	private final static String C_name = "Random-Bounce";
	@Override
	public void modify(Mod mod, GameModifier gameMod, Player player) {
		super.modify(mod, gameMod, player);
		gameMod.addModActive(mod);
		//this is what the mod does
		gameMod.setAllWallBounce(new BounceRandom());
		gameMod.setAllSliderBehaviour(new BounceRandom());
		//turn the timer on
		mod.setTimerOn(true);
		gameMod.addActivation(C_name);
	}

	@Override
	public void deModify(Mod mod, GameModifier gameMod, Player player) {
		gameMod.removeModActive(mod);
		gameMod.subtractActivation(C_name);
		if(gameMod.getActivations(C_name) <= 0){
			gameMod.setAllWallBounce(new BounceMirror());
			gameMod.setAllSliderBehaviour(new BounceMirror());
			gameMod.removeActivation(C_name);
		}
	}

	@Override
	public ModState getType() {
		return ModState.global;
	}

}
